package com.tms.app.tms.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tms.app.tms.R;
import com.tms.app.tms.bean.Fee;
import com.tms.app.tms.bean.TestBean;
import com.tms.app.tms.utils.TimeUtil;

/**
 * Created by happy on 2017/8/26.
 */

public class FeeInfoAdapter extends BaseQuickAdapter<Fee, BaseViewHolder> {
    public FeeInfoAdapter() {
        super(R.layout.item_layout_fee_info);
    }



    @Override
    protected void convert(BaseViewHolder helper, Fee item) {
        helper.setText(R.id.text_fee_type,"费用类型："+item.getFeeTypeName());
        helper.setText(R.id.text_fee_price,"金额：￥"+item.getFeeValue()+"");
        if (item.getRemark()!=null)
            helper.setText(R.id.text_mark,item.getRemark()+"");
        if (item.getShowType()==0){
            helper.getView(R.id.layout_1).setVisibility(View.GONE);
            helper.getView(R.id.text_del).setVisibility(View.INVISIBLE);
            helper.getView(R.id.text_edit).setVisibility(View.INVISIBLE);


        }else {
            switch (item.getPlanIdShowType()) {//派车单状态 0 待执行，1执行中，2 司机已完成3，确认已完成
                case 11:
                case 1:
                case 2:
                case 12:
                    break;
                case 3:
                case 13:
                    helper.getView(R.id.text_del).setVisibility(View.INVISIBLE);
                    helper.getView(R.id.text_edit).setVisibility(View.INVISIBLE);
                    break;

            }
        }
        try {
            String time=item.getRequestTime();
            if (time==null||time.length()<1)
                time=item.getCreatedTime();
            time=time .substring(0,12);
            helper.setText(R.id.time, TimeUtil.getTimeFormat(time));
        } catch (Exception e) {
            e.printStackTrace();
        }
        helper.addOnClickListener(R.id.text_del);
        helper.addOnClickListener(R.id.text_edit);
    }
}
